package com.mfp.java.testYou.ui;

import javax.servlet.ServletRequest;

import com.mfp.java.testYou.core.utils.UrlUtils;

public class UIHelper {

	public static final String SESSION_ATTR_LANG = "currentLanguage";

	private static final String DEFAULT_LANG = "en";

	private UIHelper() {
	}

	/**
	 * Returns the current language
	 * 
	 * @param request
	 * @return en|ro
	 */
	public static String getLang(ServletRequest request) {
		Object lang = UrlUtils.wrapRequest(request).getSession().getAttribute(SESSION_ATTR_LANG);
		if (lang == null) {
			lang = DEFAULT_LANG;
		}
		return lang.toString();
	}
}
